Skip to content

fix(toolkit)!: the DPKT, Scapy and PyPCAPFile IPv4 adapters still dismiss DF-set fragments (#3216) - #3220

Open
JarryShaw wants to merge 1 commit into
developfrom
fix/3216-ipv4-adapters-df-fragments
Open

JarryShaw wants to merge 1 commit into
developfrom
fix/3216-ipv4-adapters-df-fragments

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

  • Put an x into every box [ ] that applies to your pull request (like this: [x])

  • Use the Preview tab to see how your pull request will look

  • Searched for similar pull requests

  • Followed the coding style (make pylint, make mypy, make isort)

  • make test passes, and a test case covers the change

  • Described the user-visible change below and left its changelog entry to the maintainer, keeping docs/source/changelog/ and CHANGELOG.md out of the diff, if the change is user-visible: N/A — centralised

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect

  • feat — adds a feature

  • perf — changes performance, not behaviour

  • refactor — changes neither behaviour nor performance

  • test — tests only

  • docs — documentation only

  • ci — workflows or build tooling

  • release — bumps the version or rolls up a distribution

  • chore — anything else

  • Also tick if it regenerates constant or registry tables, members keeping their numeric values (the const label)


Description of your pull request and other information

Closes #3216.

Tests: the new assertions fail on an origin/develop export (the three adapters' unit tests and both parity tests; PyPCAPFile on PyPy 3.10 with pypcapfile 0.12.0) and pass here. Coverage of the three modules is unchanged and every changed line is covered. tests/toolkit, tests/foundation, tests/integration, tests/protocols, tests/project, tests/*.py and the Sphinx-gated tests/project modules pass, but for test_release_version_check_scripts_1967.py's "the fetch was killed" case, which fails the same way on a develop export (this host's shell prints a job number before Terminated).

@JarryShaw JarryShaw added the bug Issues reporting a defect (set by the bug report template; a default, not an assessment) label Nov 29, 2026
@JarryShaw JarryShaw changed the title fix(toolkit): the DPKT, Scapy and PyPCAPFile IPv4 adapters still dismiss DF-set fragments (#3216) fix(toolkit)!: the DPKT, Scapy and PyPCAPFile IPv4 adapters still dismiss DF-set fragments (#3216) Nov 29, 2026
@JarryShaw JarryShaw added breaking Breaks public-facing behaviour or API (apply alongside the type label) review: running A cross-review is in flight against the current head - no verdict yet labels Nov 29, 2026
@github-actions github-actions Bot added this to the PyPCAPKit v1.10 milestone Nov 29, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 29, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

…miss DF-set fragments (#3216)

- toolkit.dpkt, toolkit.scapy and toolkit.pypcapfile ipv4_reassembly hand
  over a fragment (MF set or a non-zero offset) whatever its DF flag, and no
  whole datagram, as toolkit.pcap._ipv4_fragment does (#2961).
- Scapy's zero-length-frame guard goes: the IPv4 layer of defaults Scapy
  builds for one is no fragment, so the new check dismisses it.
- New generated fixture ipv4-frag.pcap: whole datagrams with DF set and
  clear, a DF-clear datagram in three fragments, one out of order, and a
  DF-set fragment pair; asserted end to end and for engine parity.
- Tests that fed these adapters whole datagrams feed first fragments.
@JarryShaw
JarryShaw force-pushed the fix/3216-ipv4-adapters-df-fragments branch from 004d3cf to 301393b Compare November 29, 2026 08:24
@JarryShaw

Copy link
Copy Markdown
Owner Author

Good to go at 301393bfc, from a Sonnet cross-review and my check of the amend.

  • All three adapters match toolkit.pcap._ipv4_fragment on every DF/MF/offset combination: a fragment is handed over whatever DF says, and a whole datagram never is. Scapy's fix(toolkit): scapy ends the extraction on a zero-length RAW frame when IPv4 reassembly is on #1676 guard can no longer be reached, because IP(b'') is never a fragment.
  • ipv4-frag.pcap checks out on checksums and lengths. On develop it reproduces the bug: DPKT and Scapy drop the DF-set pair. The new tests fail on develop, and no rewritten test asserts less than before.
  • It is breaking, because a direct adapter call on a whole datagram now returns None. The subject now carries !, and the tree is identical to the reviewed 004d3cffb.
  • Unverified: the PyPCAPFile engine end to end, since pypcapfile needs Python < 3.12 here. The worker ran it on PyPy 3.10, and adapter-level parity passed.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Nov 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 94.97% (unit tier, Python 3.15, 301393bfc, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 116 4 20 2 95.59%
pcapkit/const 22386 224 3186 191 98.28%
pcapkit/corekit 3160 83 1058 40 96.85%
pcapkit/dumpkit 423 3 148 5 98.60%
pcapkit/foundation 4348 24 1364 26 99.12%
pcapkit/interface 112 4 40 3 95.39%
pcapkit/protocols 28918 152 7662 127 99.23%
pcapkit/toolkit 1219 35 440 9 96.50%
pcapkit/utilities 638 7 176 5 98.53%
pcapkit/vendor 6575 2396 1478 258 60.24%

Per-file detail: the coverage-html artifact of this run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaks public-facing behaviour or API (apply alongside the type label) bug Issues reporting a defect (set by the bug report template; a default, not an assessment) review: good-to-go Cross-review at the current head says ready; CI state is separate

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

1 participant